package com.example.dao;

import com.example.domain.Permission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Date: 2021年08月21日 16:44
 * @Author: LHSAMA
 */
public interface IPermissionDao {

    @Select("select * from permission where id in (select permissionId from role_permission where roleId = #{roleId} )")
    List<Permission> findByRoleId(String roleId)throws Exception;

    @Select("select * from permission")
    List<Permission> findAll();

    @Insert("insert into permission(permissionName,url) values(#{permissionName},#{url})")
    void save(Permission permission);

    @Delete("delete from role_permission where permissionId = #{id}")
    void deleteRolePermission(String id);

    @Delete("delete from permission where id = #{id}")
    void deletePermission(String id);
}
